// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
const db=cloud.database();
// 云函数入口函数
exports.main = async (event, context) => {
  const {dailyname,dailysingle,time,eat,account}=event
  try {
    const createRes = await db.collection("dailymedicine").add({
      data: {
        dailyname,
        dailysingle,
        time,
        eat,
        account
      }
    })
    return {
      success: true,
      message: '上传成功',
    };
  }
  catch (err) {
    console.error('添加失败:', err)
    return {
      success: false,
      message: '添加失败，请稍后重试'
    }
  }
}
